import { Component, OnInit, OnDestroy } from '@angular/core';
import { MessageService } from 'src/app/core/service/message.service';
import { ApiService } from 'src/app/core/api';
import { NzMessageService } from 'ng-zorro-antd';
import { NzRateModule } from 'ng-zorro-antd/rate';
import { ActivatedRoute } from '@angular/router';

@Component({
    templateUrl: './myReport.html',
    styleUrls: ['./myReport.scss']
})
export class MyReportComponent implements OnInit, OnDestroy {
    dataList = [
        {itemId:1,name:'网络摄像机检测网络摄像机检测网络摄像 机检测网络摄像机检测网络摄像机检测',price:'299.00',thumbnail:'../../../../../assets/img/image1.png'}
    ];
    page={
        pageNo:1,
        pages:0
    }
    ngOnInit() {
        this.message.sendMessage('setHeader','bgnone');
       this.getList();
    }
    getList(){
        this.api.post('收藏列表', this.page).then(res => {
            this.dataList = res['data']['list'];
            this.page.pageNo = res['data']['pageNo'];
            this.page.pages = res['data']['pages'];
        })
    }
    ngOnDestroy(){
        this.message.sendMessage('setHeader','');
    }
    delete(itemId){
        this.api.post('取消收藏项目', {itemId:itemId}).then(res => {
            this.msg.success('已取消');
            this.getList();
        }).catch((res) => {
            this.msg.error(res.message);
		});
    }
    constructor(
        private message: MessageService,
        private msg: NzMessageService,
        private api: ApiService,
        private route: ActivatedRoute
    ) { }
}